//
//  UIButton+xib.swift
//  EPHome
//
//  Created by liujianlong on 2022/8/9.
//

import Foundation
import UIKit
private var textHightLightKey = "cornarRadiusKey"
private var textSelectedKey = "backGroundHexColorKey"
private var textDisabledKey = "borderHexColorKey"
private var bgDisabledKey = "bgDisabledKey"

extension UIButton
{
    @IBInspectable var textHightLightColor:String{
        set{
            objc_setAssociatedObject(self, &textHightLightKey, newValue, .OBJC_ASSOCIATION_COPY_NONATOMIC)
            if newValue == "" {return}
            self.setTitleColor(newValue.color(), for: .highlighted)
        }get{
            return objc_getAssociatedObject(self, &textHightLightKey) as? String ?? "#FFFFFF"
        }
    }
    @IBInspectable var textSelectedColor:String{
        set{
            objc_setAssociatedObject(self, &textSelectedKey, newValue, .OBJC_ASSOCIATION_COPY_NONATOMIC)
            if newValue == "" {return}
            self.setTitleColor(newValue.color(), for: .selected)
        }get{
            return objc_getAssociatedObject(self, &textSelectedKey) as? String ?? "#FFFFFF"
        }
    }
    @IBInspectable var textDisabledColor:String{
        set{
            objc_setAssociatedObject(self, &textDisabledKey, newValue, .OBJC_ASSOCIATION_COPY_NONATOMIC)
            if newValue == "" {return}
            self.setTitleColor(newValue.color(), for: .disabled)
        }get{
            return objc_getAssociatedObject(self, &textDisabledKey) as? String ?? "#FFFFFF"
        }
    }
}
